//
//  MyHospitalCollectionView.m
//  WE
//
//  Created by 要帅气的生活 on 15/11/26.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "MyHospitalCollectionView.h"

static BOOL state = YES;
@implementation MyHospitalCollectionView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _button = [UIButton buttonWithType:UIButtonTypeSystem];
        _button.frame = CGRectMake(10, 10, self.frame.size.width/5, self.frame.size.height-20);
        [self addSubview:_button];
        _button.backgroundColor = [UIColor yellowColor];
        
        _nema = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width/5+20, 10, self.frame.size.width/5*3, (self.frame.size.height-20)/3)];
        _nema.font = [UIFont systemFontOfSize:14];
        [self addSubview:_nema];
        _nema.backgroundColor = [UIColor blueColor];
        
        _level = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width/5+20, (self.frame.size.height-20)/3+10, self.frame.size.width/5*3, (self.frame.size.height-20)/3)];
        _level.font = [UIFont systemFontOfSize:13];
        _level.alpha = 0.4;
        [self addSubview:_level];
        _level.backgroundColor = [UIColor redColor];
        
        _reservations = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width/5+20, (self.frame.size.height-20)/3*2+10, self.frame.size.width/5*3, (self.frame.size.height-20)/3)];
        _reservations.font = [UIFont systemFontOfSize:13];
        _reservations.alpha = 0.4;
        [self addSubview:_reservations];
        _reservations.backgroundColor = [UIColor purpleColor];
        
        _view = [[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width-self.frame.size.height/3 -10, self.frame.size.height/3, self.frame.size.height/3, self.frame.size.height/3)];
        _view.layer.cornerRadius = self.frame.size.height/6;
        _view.layer.borderWidth = 0.5;
        _view.layer.borderColor = GREENCOLOR.CGColor;
        [self addSubview:_view];
        
        _viewgreen = [[UIView alloc] initWithFrame:CGRectMake(3, 3, _view.frame.size.width-6, _view.frame.size.width-6)];
        _viewgreen.layer.cornerRadius = _view.frame.size.width/2-3;
        [_view addSubview:_viewgreen];
        _viewgreen.backgroundColor = [UIColor greenColor];
        
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(3, 3, _viewgreen.frame.size.width-6, _viewgreen.frame.size.width-6)];
        _img.image = [UIImage imageNamed:@"goubai.png"];
        [_viewgreen addSubview:_img];
        
        [self addTarget:self selector:@selector(guanzhu)];
    }
    return self;
}

-(void)guanzhu{
    if (state == YES) {
        _viewgreen.backgroundColor = [UIColor clearColor];
        state = NO;
    }else{
        state = YES;
        _viewgreen.backgroundColor = [UIColor greenColor];
    }
}
- (UIViewController *)viewController{
    for (UIView *next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}


@end
